home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Freeware / reportplus / source / f7.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  20.1 KB  |  643 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <intuition/intuition.h>
  4. #include <intuition/gadgetclass.h>
  5. #include <libraries/gadtools.h>
  6. #include <dos/dosextens.h>
  7. #include <graphics/gfx.h>
  8.  
  9. #include <clib/exec_protos.h>
  10. #include <clib/intuition_protos.h>
  11. #include <clib/gadtools_protos.h>
  12. #include <clib/dos_protos.h>
  13. #include <clib/graphics_protos.h>
  14.  
  15. #include <ctype.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "rp.h"
  19.  
  20. #define AMIGA 0
  21. #define MAC   1
  22. #define IBM   2
  23.  
  24. MODULE void updatedetabulate(void);
  25. MODULE ABOOL spaceeol(TEXT nextchar);
  26.  
  27. MODULE  struct Gadget *MX71_Source      = NULL,
  28.                       *TE71_SourceTitle = NULL,
  29.                       *MX71_Dest        = NULL,
  30.                       *TE71_DestTitle   = NULL,
  31.                       *ST71_Pathname    = NULL,
  32.                       *BU71_PathnameASL = NULL,
  33.                       *CB71_Detabulate  = NULL,
  34.                       *IN71_TabSize     = NULL,
  35.                       *BU71_Convert     = NULL,
  36.                       *CB71_Unwrap      = NULL;
  37. AGLOBAL struct Gadget* TE71_Status      = NULL;
  38.  
  39. // from rp.c
  40. IMPORT TEXT                IOBuffer[LONGESTFIELD + 1];
  41. IMPORT ABOOL               fillwindows, stop;
  42. IMPORT SBYTE               page;
  43. IMPORT SWORD               y;
  44. IMPORT TEXT                asldir[VLONGFIELD + 1];
  45. IMPORT ULONG               fillcolour;
  46. IMPORT struct NewGadget    Gadget;
  47. IMPORT struct Gadget      *BU99_Right,
  48.                           *BU99_Stop,
  49.                           *PrevGadPtr;
  50. IMPORT struct Window*      MainWindowPtr;
  51. IMPORT struct Screen*      ScreenPtr;
  52. IMPORT struct IconBase*    IconBase;
  53. IMPORT struct SharedStruct shared;
  54.  
  55. MODULE struct
  56. {   ABOOL detabulate, unwrap;
  57.     UWORD source, dest;
  58.     ULONG tabsize;
  59. } eol =
  60. {   FALSE, FALSE, IBM, AMIGA, 8
  61. };
  62.  
  63. // EOL/tab converter
  64. MODULE  STRPTR EOLOptions[4] =
  65. {   (STRPTR) "LF    (Amiga)",
  66.     (STRPTR) "CR    (Macintosh)",
  67.     (STRPTR) "CR+LF (IBM-PC)",
  68.     NULL
  69. };
  70.  
  71. AGLOBAL void eol1(void)
  72. {   shared.pathname[0] = 0;
  73.  
  74.     verynewwindow
  75.     (   EOL1WIDTH, EOL1HEIGHT,
  76.         "Report+: EOL/Tab Converter",
  77.         BUTTONIDCMP | STRINGIDCMP | MXIDCMP
  78.     );
  79.     if (fillwindows)
  80.     {   SetAPen(MainWindowPtr->RPort, 0);
  81.         RectFill(MainWindowPtr->RPort, 80, 146, EOL1WIDTH - 10, 146 + 12); // TE71_Status
  82.     }
  83.  
  84.     /* source title */
  85.     setgadget(62 + 2, 40, 100, 12, "_Source:", PLACETEXT_ABOVE);
  86.     // be sure this never overlaps with MX71_Source
  87.     TE71_SourceTitle = PrevGadPtr = (struct Gadget *) CreateGadget
  88.     (   TEXT_KIND,
  89.         PrevGadPtr,
  90.         &Gadget,
  91.         GT_Underscore, '_',
  92.         TAG_DONE
  93.     );
  94.     /* source format */
  95.     setgadget(62, 50, 0, 0, NULL, PLACETEXT_RIGHT);
  96.     MX71_Source = PrevGadPtr = (struct Gadget *) CreateGadget
  97.     (   MX_KIND,
  98.         PrevGadPtr,
  99.         &Gadget,
  100.         GTMX_Labels, &EOLOptions,
  101.         GTMX_Active, eol.source,
  102.         TAG_DONE
  103.     );
  104.     /* dest title */
  105.     setgadget(314 + 22, 40, 100, 12, "_Destination:", PLACETEXT_ABOVE);
  106.     // be sure this never overlaps with MX71_Dest
  107.     TE71_DestTitle = PrevGadPtr = (struct Gadget *) CreateGadget
  108.     (   TEXT_KIND,
  109.         PrevGadPtr,
  110.         &Gadget,
  111.         GT_Underscore, '_',
  112.         TAG_DONE
  113.     );
  114.     /* destination format */
  115.     setgadget(314, 50, 0, 0, NULL, PLACETEXT_RIGHT);
  116.     MX71_Dest = PrevGadPtr = (struct Gadget *) CreateGadget
  117.     (   MX_KIND,
  118.         PrevGadPtr,
  119.         &Gadget,
  120.         GTMX_Labels, &EOLOptions,
  121.         GTMX_Active, eol.dest,
  122.         TAG_DONE
  123.     );
  124.  
  125.     /* pathname */
  126.     setgadget(132, 88, 340, 12, "_Pathname(s):", NULL);
  127.     ST71_Pathname = PrevGadPtr = (struct Gadget *) CreateGadget
  128.     (   STRING_KIND,
  129.         PrevGadPtr,
  130.         &Gadget,
  131.         GTST_String, shared.pathname,
  132.         GTST_MaxChars, LONGESTFIELD,
  133.         GA_TabCycle, TRUE,
  134.         GT_Underscore, '_',
  135.         TAG_DONE
  136.     );
  137.     /* pathname... */
  138.     setgadget(474, 88, 28, 12, "_...", NULL);
  139.     BU71_PathnameASL = PrevGadPtr = (struct Gadget *) CreateGadget
  140.     (   BUTTON_KIND,
  141.         PrevGadPtr,
  142.         &Gadget,
  143.         GT_Underscore, '_',
  144.         TAG_DONE
  145.     );
  146.  
  147.     // 'convert tabs to spaces?'
  148.     setgadget(294, 110, 0, 0, "C_onvert tabs to spaces?", NULL);
  149.     CB71_Detabulate = PrevGadPtr = (struct Gadget *) CreateGadget
  150.     (   CHECKBOX_KIND,
  151.         PrevGadPtr,
  152.         &Gadget,
  153.         GTCB_Checked, eol.detabulate,
  154.         GT_Underscore, '_',
  155.         TAG_DONE
  156.     );
  157.     /* tab size */
  158.     setgadget(408, 110, 32, 12, "_Tab size:", NULL);
  159.     IN71_TabSize = PrevGadPtr = (struct Gadget *) CreateGadget
  160.     (   INTEGER_KIND,
  161.         PrevGadPtr,
  162.         &Gadget,
  163.         GTIN_Number, eol.tabsize,
  164.         GTIN_MaxChars, 2,
  165.         GA_TabCycle, TRUE,
  166.         GT_Underscore, '_',
  167.         TAG_DONE
  168.     );
  169.  
  170.     setgadget(294, 122, 0, 0, "_Unwrap words?", NULL);
  171.     CB71_Unwrap = PrevGadPtr = (struct Gadget *) CreateGadget
  172.     (   CHECKBOX_KIND,
  173.         PrevGadPtr,
  174.         &Gadget,
  175.         GTCB_Checked, eol.unwrap,
  176.         GT_Underscore, '_',
  177.         TAG_DONE
  178.     );
  179.  
  180.     setgadget(80, 146, EOL1WIDTH - 80 - 10, 12, "Status:", NULL);
  181.     TE71_Status = PrevGadPtr = (struct Gadget *) CreateGadget
  182.     (   TEXT_KIND,
  183.         PrevGadPtr,
  184.         &Gadget,
  185.         GTTX_Text, "Ready.",
  186.         GTTX_Border, TRUE,
  187.         TAG_DONE
  188.     );
  189.     setgadget(10, EOL1HEIGHT - 28, (EOL1WIDTH / 2) - 10, 12, "_Convert", NULL);
  190.     BU71_Convert = PrevGadPtr = (struct Gadget *) CreateGadget
  191.     (   BUTTON_KIND,
  192.         PrevGadPtr,
  193.         &Gadget,
  194.         GT_Underscore, '_',
  195.         TAG_DONE
  196.     );
  197.     setgadget(EOL1WIDTH / 2, EOL1HEIGHT - 28, (EOL1WIDTH / 2) - 10, 12, "Stop", NULL);
  198.     BU99_Stop = PrevGadPtr = (struct Gadget *) CreateGadget
  199.     (   BUTTON_KIND,
  200.         PrevGadPtr,
  201.         &Gadget,
  202.         GT_Underscore, '_',
  203.         GA_Disabled, TRUE,
  204.         TAG_DONE
  205.     );
  206.  
  207.     drawgadgets((UWORD) ~0);
  208.     ActivateGadget(ST71_Pathname, MainWindowPtr, NULL);
  209.     if (eol.detabulate)
  210.     {   GT_SetGadgetAttrs
  211.         (   IN71_TabSize,
  212.             MainWindowPtr, NULL,
  213.             GA_Disabled, FALSE,
  214.             TAG_DONE
  215.         );
  216.     } else
  217.     {   GT_SetGadgetAttrs
  218.         (   IN71_TabSize,
  219.             MainWindowPtr, NULL,
  220.             GA_Disabled, TRUE,
  221.             TAG_DONE
  222.         );
  223.     }
  224.     loop();
  225.     closewindow();
  226. }
  227.  
  228. AGLOBAL void eol_do(void)
  229. {   strcpy
  230.     (   shared.pathname,
  231.         ((struct StringInfo *) ST71_Pathname->SpecialInfo)->Buffer
  232.     );
  233.     eol.tabsize = ((struct StringInfo *) IN71_TabSize->SpecialInfo)->LongInt;
  234.  
  235.     GT_SetGadgetAttrs
  236.     (   BU99_Stop,
  237.         MainWindowPtr, NULL,
  238.         GA_Disabled, FALSE,
  239.         TAG_DONE
  240.     );
  241.     GT_SetGadgetAttrs
  242.     (   MX71_Source,
  243.         MainWindowPtr, NULL,
  244.         GA_Disabled, TRUE,
  245.         TAG_DONE
  246.     );
  247.     GT_SetGadgetAttrs
  248.     (   MX71_Dest,
  249.         MainWindowPtr, NULL,
  250.         GA_Disabled, TRUE,
  251.         TAG_DONE
  252.     );
  253.     GT_SetGadgetAttrs
  254.     (   ST71_Pathname,
  255.         MainWindowPtr, NULL,
  256.         GA_Disabled, TRUE,
  257.         TAG_DONE
  258.     );
  259.     GT_SetGadgetAttrs
  260.     (   BU71_PathnameASL,
  261.         MainWindowPtr, NULL,
  262.         GA_Disabled, TRUE,
  263.         TAG_DONE
  264.     );
  265.     GT_SetGadgetAttrs
  266.     (   CB71_Detabulate,
  267.         MainWindowPtr, NULL,
  268.         GA_Disabled, TRUE,
  269.         TAG_DONE
  270.     );
  271.     GT_SetGadgetAttrs
  272.     (   IN71_TabSize,
  273.         MainWindowPtr, NULL,
  274.         GA_Disabled, TRUE,
  275.         TAG_DONE
  276.     );
  277.     GT_SetGadgetAttrs
  278.     (   BU71_Convert,
  279.         MainWindowPtr, NULL,
  280.         GA_Disabled, TRUE,
  281.         TAG_DONE
  282.     );
  283.     GT_SetGadgetAttrs
  284.     (   BU99_Right,
  285.         MainWindowPtr, NULL,
  286.         GA_Disabled, TRUE,
  287.         TAG_DONE
  288.     );
  289.  
  290.     convert(TRUE);
  291.  
  292.     if (!stop)
  293.     {   GT_SetGadgetAttrs
  294.         (   TE71_Status,
  295.             MainWindowPtr, NULL,
  296.             GTTX_Text, "All done.",
  297.             TAG_DONE
  298.         );
  299.     }
  300.     GT_SetGadgetAttrs
  301.     (   BU99_Stop,
  302.         MainWindowPtr, NULL,
  303.         GA_Disabled, TRUE,
  304.         TAG_DONE
  305.     );
  306.     GT_SetGadgetAttrs
  307.     (   MX71_Source,
  308.         MainWindowPtr, NULL,
  309.         GA_Disabled, FALSE,
  310.         TAG_DONE
  311.     );
  312.     GT_SetGadgetAttrs
  313.     (   MX71_Dest,
  314.         MainWindowPtr, NULL,
  315.         GA_Disabled, FALSE,
  316.         TAG_DONE
  317.     );
  318.     GT_SetGadgetAttrs
  319.     (   ST71_Pathname,
  320.         MainWindowPtr, NULL,
  321.         GA_Disabled, FALSE,
  322.         TAG_DONE
  323.     );
  324.     GT_SetGadgetAttrs
  325.     (   BU71_PathnameASL,
  326.         MainWindowPtr, NULL,
  327.         GA_Disabled, FALSE,
  328.         TAG_DONE
  329.     );
  330.     GT_SetGadgetAttrs
  331.     (   CB71_Detabulate,
  332.         MainWindowPtr, NULL,
  333.         GA_Disabled, FALSE,
  334.         TAG_DONE
  335.     );
  336.     GT_SetGadgetAttrs
  337.     (   IN71_TabSize,
  338.         MainWindowPtr, NULL,
  339.         GA_Disabled, FALSE,
  340.         TAG_DONE
  341.     );
  342.     GT_SetGadgetAttrs
  343.     (   BU71_Convert,
  344.         MainWindowPtr, NULL,
  345.         GA_Disabled, FALSE,
  346.         TAG_DONE
  347.     );
  348.     GT_SetGadgetAttrs
  349.     (   BU99_Right,
  350.         MainWindowPtr, NULL,
  351.         GA_Disabled, FALSE,
  352.         TAG_DONE
  353.     );
  354. }
  355.  
  356. AGLOBAL void eolconvert(ABOOL gui)
  357. {   ULONG                gap, i, j, cursorx = 0;
  358.     ABOOL                ok                 = TRUE;
  359.     struct FileInfoBlock InputInfoBlock;
  360.     UBYTE*               InputBufferPtr; // always use UBYTE not APTR for pointer arithmetic
  361.     BPTR                 FileHandle;
  362.     TEXT                 saystring[VLONGFIELD + 1];
  363.  
  364.     strcpy(saystring, "Converting ");
  365.     strcat(saystring, shared.thisfile);
  366.     strcat(saystring, "...");
  367.     if (gui)
  368.     {   GT_SetGadgetAttrs
  369.         (   TE71_Status,
  370.             MainWindowPtr, NULL,
  371.             GTTX_Text, saystring,
  372.             TAG_DONE
  373.         );
  374.     } else
  375.     {   Printf("%s", saystring);
  376.         Flush(Output());
  377.     }
  378.  
  379.     if (FileHandle = (BPTR) Lock(shared.thisfile, ACCESS_READ))
  380.     {   if (Examine(FileHandle, &InputInfoBlock))
  381.         {   UnLock(FileHandle);
  382.             // FileHandle = NULL;
  383.             if (InputInfoBlock.fib_DirEntryType == -3) // if a file
  384.             {   // if it is a directory, we would ideally like to convert all
  385.                 // files in that directory. We also should support links.
  386.                 if (InputBufferPtr = AllocMem(InputInfoBlock.fib_Size, MEMF_ANY | MEMF_PUBLIC))
  387.                 {   if (FileHandle = (BPTR) Open(shared.thisfile, MODE_OLDFILE))
  388.                     {   if (Read(FileHandle, InputBufferPtr, InputInfoBlock.fib_Size) != -1)
  389.                         {   Close(FileHandle);
  390.                             if (FileHandle = (BPTR) Open(shared.thisfile, MODE_NEWFILE))
  391.                             {   for (i = 0; i < InputInfoBlock.fib_Size; i++)
  392.                                 {   if (*(InputBufferPtr + i) == LF)
  393.                                     {   if (eol.unwrap && (eol.source == AMIGA || eol.source == IBM) && spaceeol(*(InputBufferPtr + i + 1)))
  394.                                         {   cursorx++;
  395.                                             FPutC(FileHandle, ' ');
  396.                                         } else
  397.                                         {   cursorx = 0;
  398.  
  399.                                             if (eol.source == eol.dest)
  400.                                                 FPutC(FileHandle, LF); // pass it through
  401.                                             elif (eol.source == AMIGA && eol.dest == IBM)
  402.                                             {   FPutC(FileHandle, CR); // add this
  403.                                                 FPutC(FileHandle, LF); // and pass this through
  404.                                             } elif (eol.source == AMIGA && eol.dest == MAC)
  405.                                                 FPutC(FileHandle, CR); // convert from LF to CR
  406.                                             elif (eol.source == IBM && eol.dest == AMIGA)
  407.                                                 FPutC(FileHandle, LF); // pass it through
  408.                                             elif (eol.source == IBM && eol.dest == MAC)
  409.                                                 ; // do nothing
  410.                                             else ; // mac as source: we never expect LFs
  411.                                     }   }
  412.                                     elif (*(InputBufferPtr + i) == CR)
  413.                                     {   if (eol.unwrap && eol.source == MAC && spaceeol(*(InputBufferPtr + i + 1)))
  414.                                         {   cursorx++;
  415.                                             FPutC(FileHandle, ' ');
  416.                                         } else
  417.                                         {   cursorx = 0;
  418.  
  419.                                             if (eol.source == eol.dest)
  420.                                                 FPutC(FileHandle, CR); // pass it through
  421.                                             elif (eol.source == IBM && eol.dest == AMIGA)
  422.                                                 ; // do nothing
  423.                                             elif (eol.source == IBM && eol.dest == MAC)
  424.                                                 FPutC(FileHandle, CR); // pass it through
  425.                                             elif (eol.source == MAC && eol.dest == AMIGA)
  426.                                                 FPutC(FileHandle, LF); // convert from CR to LF
  427.                                             elif (eol.source == MAC && eol.dest == IBM)
  428.                                             {   FPutC(FileHandle, CR); // pass this through
  429.                                                 FPutC(FileHandle, LF); // and add this
  430.                                             } else ; // amiga as source: we never expect CRs
  431.                                     }   }
  432.                                     elif (*(InputBufferPtr + i) == TAB)
  433.                                     {   if (eol.detabulate)
  434.                                         {   gap = (((cursorx / eol.tabsize) + 1) * eol.tabsize) - cursorx;
  435.                                             for (j = 1; j <= gap; j++)
  436.                                                 FPutC(FileHandle, ' ');
  437.                                             cursorx += gap;
  438.                                         } else FPutC(FileHandle, TAB); // no point to cursorx in non-detabulate
  439.                                     } else
  440.                                     {   FPutC(FileHandle, *(InputBufferPtr + i));
  441.                                         cursorx++;
  442.                                 }   }
  443.                                 /* Note that FPutC() returns EOF for errors; this is not currently
  444.                                 checked. */
  445.                                 ok = TRUE;
  446.                                 Close(FileHandle);
  447.                         }   }
  448.                         else
  449.                         {   Close(FileHandle);
  450.                     }   }
  451.                     FreeMem(InputBufferPtr, InputInfoBlock.fib_Size);
  452.         }   }   }
  453.         else
  454.         {   UnLock(FileHandle);
  455.     }   }
  456.  
  457.     if (gui)
  458.     {   if (ok)
  459.             strcat(saystring, "done.");
  460.         else strcat(saystring, "failed!");
  461.         GT_SetGadgetAttrs
  462.         (   TE71_Status,
  463.             MainWindowPtr, NULL,
  464.             GTTX_Text, saystring,
  465.             TAG_DONE
  466.         );
  467.     } else
  468.     {   if (ok)
  469.             Printf("done.\n");
  470.         else Printf("failed!\n");
  471.     }
  472.  
  473.     checkabort(gui);
  474. }
  475.  
  476. AGLOBAL void eol_loop(ULONG class, struct Gadget* addr, UWORD code, UWORD qual)
  477. {   if (page == 71)
  478.     {   if (class == IDCMP_VANILLAKEY)
  479.         {   code = toupper(code);
  480.             if (code == 'S')
  481.             {   if (!(qual & IEQUALIFIER_LSHIFT) && !(qual & IEQUALIFIER_RSHIFT))
  482.                 {   if (eol.source < 2)
  483.                         eol.source++;
  484.                     else eol.source = 0;
  485.                 } else
  486.                 {   if (eol.source > 0)
  487.                         eol.source--;
  488.                     else eol.source = 2;
  489.                 }
  490.                 GT_SetGadgetAttrs
  491.                 (   MX71_Source,
  492.                     MainWindowPtr,
  493.                     NULL,
  494.                     GTMX_Active, eol.source,
  495.                     TAG_DONE
  496.                 );
  497.             } elif (code == 'D')
  498.             {   if (!(qual & IEQUALIFIER_LSHIFT) && !(qual & IEQUALIFIER_RSHIFT))
  499.                 {   if (eol.dest < 2)
  500.                         eol.dest++;
  501.                     else eol.dest = 0;
  502.                 } else
  503.                 {   if (eol.dest > 0)
  504.                         eol.dest--;
  505.                     else eol.dest = 2;
  506.                 }
  507.                 GT_SetGadgetAttrs
  508.                 (   MX71_Dest,
  509.                     MainWindowPtr,
  510.                     NULL,
  511.                     GTMX_Active, eol.dest,
  512.                     TAG_DONE
  513.                 );
  514.             } elif (code == 'O')
  515.             {   if (CB71_Detabulate->Flags & GFLG_SELECTED)
  516.                 {   eol.detabulate = FALSE;
  517.                 } else eol.detabulate = TRUE;
  518.                 updatedetabulate();
  519.             } elif (code == 'U')
  520.             {   if (CB71_Unwrap->Flags & GFLG_SELECTED)
  521.                 {   eol.unwrap = FALSE;
  522.                 } else eol.unwrap = TRUE;
  523.                 GT_SetGadgetAttrs
  524.                 (   CB71_Unwrap,
  525.                     MainWindowPtr, NULL,
  526.                     GTCB_Checked, eol.unwrap,
  527.                     TAG_DONE
  528.                 );
  529.             } elif (code == 'T')
  530.             {   ActivateGadget(IN71_TabSize, MainWindowPtr, NULL);
  531.             } elif (code == 'C')
  532.             {   eol_do();
  533.             } elif (code == 'P')
  534.             {   ActivateGadget(ST71_Pathname, MainWindowPtr, NULL);
  535.             } elif (code == ESCAPE)
  536.             {   page = 0;
  537.             } elif (code == '.')
  538.             {   multiasl("~(#?.info)");
  539.                 GT_SetGadgetAttrs
  540.                 (   ST71_Pathname,
  541.                     MainWindowPtr,
  542.                     NULL,
  543.                     GTST_String, shared.pathname,
  544.                     TAG_DONE
  545.                 );
  546.         }   }
  547.         elif (class == IDCMP_GADGETDOWN)
  548.         {   // radio gadgets
  549.             if (addr == MX71_Source)
  550.                 eol.source = code;
  551.             elif (addr == MX71_Dest)
  552.                 eol.dest = code;
  553.         } elif (class == IDCMP_GADGETUP)
  554.         {   // button, etc. gadgets
  555.             if (addr == BU99_Right)
  556.                 page = 0;
  557.             elif (addr == BU71_Convert)
  558.             {   eol_do();
  559.             } elif (addr == BU71_PathnameASL)
  560.             {   multiasl("~(#?.info)");
  561.                 GT_SetGadgetAttrs
  562.                 (   ST71_Pathname,
  563.                     MainWindowPtr,
  564.                     NULL,
  565.                     GTST_String, shared.pathname,
  566.                     TAG_DONE
  567.                 );
  568.             } elif (addr == CB71_Detabulate)
  569.             {   if (CB71_Detabulate->Flags & GFLG_SELECTED)
  570.                 {   eol.detabulate = TRUE;
  571.                 } else eol.detabulate = FALSE;
  572.                 updatedetabulate();
  573.             } elif (addr == CB71_Unwrap)
  574.             {   if (CB71_Unwrap->Flags & GFLG_SELECTED)
  575.                 {   eol.unwrap = TRUE;
  576.                 } else eol.unwrap = FALSE;
  577.                 GT_SetGadgetAttrs
  578.                 (   CB71_Unwrap,
  579.                     MainWindowPtr, NULL,
  580.                     GTCB_Checked, eol.unwrap,
  581.                     TAG_DONE
  582.                 );
  583.     }   }   }
  584.     else
  585.     {   // assert(page == 72);
  586.         if (class == IDCMP_GADGETUP)
  587.         {   if (addr == BU99_Right)
  588.                 page = 0;
  589.         } elif (class == IDCMP_VANILLAKEY)
  590.         {   if (code == ESCAPE)
  591.                 page = 0;
  592. }   }   }
  593.  
  594. MODULE void updatedetabulate(void)
  595. {   GT_SetGadgetAttrs
  596.     (   CB71_Detabulate,
  597.         MainWindowPtr, NULL,
  598.         GTCB_Checked, eol.detabulate,
  599.         TAG_DONE
  600.     );
  601.     if (eol.detabulate)
  602.     {   GT_SetGadgetAttrs
  603.         (   IN71_TabSize,
  604.             MainWindowPtr, NULL,
  605.             GA_Disabled, FALSE,
  606.             TAG_DONE
  607.         );
  608.     } else
  609.     {   GT_SetGadgetAttrs
  610.         (   IN71_TabSize,
  611.             MainWindowPtr, NULL,
  612.             GA_Disabled, TRUE,
  613.             TAG_DONE
  614.         );
  615. }   }
  616.  
  617. MODULE ABOOL spaceeol(TEXT nextchar)
  618. {   if
  619.     (   nextchar == ' '
  620.      || nextchar == TAB
  621.      || nextchar == LF
  622.      || nextchar == CR
  623.     )
  624.     {   return(FALSE);
  625.     } else return(TRUE);
  626. }
  627.  
  628. AGLOBAL void eol_die(void)
  629. {   IOBuffer[1] = (UBYTE) eol.source;
  630.     IOBuffer[2] = (UBYTE) eol.dest;
  631.     IOBuffer[3] =         eol.detabulate;
  632.     IOBuffer[4] = (UBYTE) eol.tabsize;
  633.     IOBuffer[5] =         eol.unwrap;
  634. }
  635.  
  636. AGLOBAL void eol_config(void)
  637. {   eol.source     = IOBuffer[1];
  638.     eol.dest       = IOBuffer[2];
  639.     eol.detabulate = IOBuffer[3];
  640.     eol.tabsize    = IOBuffer[4];
  641.     eol.unwrap     = IOBuffer[5];
  642. }
  643.